package com.xuanyuanzi.all_learning.infrastructure.common.thread;

import com.xuanyuanzi.all_learning.domain.model.sys.User;

/**
 * 登陆用户上下文
 */
public class CurrentThread {

    private static ThreadLocal<User> localUser = new ThreadLocal<User>();

    /**
     * 设置登陆用户
     *
     * @param user
     */
    public static void setUser(User user) {
        localUser.set(user);
    }

    /**
     * 获取登陆用户
     *
     * @return
     */
    public static User getUser() {
        return localUser.get();
    }

    public static ThreadLocal<User> getUserLocal() {
        return localUser;
    }

}
